import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import svgLoader from 'vite-svg-loader'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    svgLoader({
      svgoConfig: {
        multipass: true
      }
    })
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
      'cesium': resolve(__dirname, 'node_modules/cesium/Build/Cesium')
    }
  },
  server: {
    port: 5173
  },
  // Cesium配置
  optimizeDeps: {
    exclude: ['cesium'],
    include: ['nosleep.js']
  },
  build: {
    rollupOptions: {
      external: ['cesium'],
      output: {
        manualChunks: {
          'cesium': ['cesium']
        }
      }
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "${resolve(__dirname, 'node_modules/cesium/Build/Cesium/Widgets/widgets.css')}";`
      }
    }
  }
})
